

class EventObj {
    constructor() {
        this.eventObj = {}
    }
    addEvent(eventName, event) {
        if (this.eventObj[eventName] == undefined) {
            this.eventObj[eventName] = []
        }
        this.eventObj[eventName].push(event)
    }
    trigger(eventName) {
        if (typeof this.eventObj[eventName] !== "undefined") {
            this.eventObj[eventName].forEach(function (item) {
                item()
            })
        } else {
            throw Error('参数传递错误')
        }
    }
}
export default EventObj
